package com.xinhe.web.controller;

import com.querydsl.core.QueryResults;
import com.xinhe.web.annotation.WebUsed;
import com.xinhe.web.common.Result;
import com.xinhe.web.entity.LogisticsCompany;
import com.xinhe.web.service.LogisticsCompanyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@Api(value = "物流公司", tags = {"物流公司"})
@RestController
@RequestMapping(value = {"/logisticsCompany"}, produces = {"application/json;charset=UTF-8"})

public class LogisticsCompanyController {
    @Autowired
    private LogisticsCompanyService logisticsCompanyService;

    @WebUsed
    @ApiOperation(httpMethod = "GET", value = "分页查询物流公司")
    @RequestMapping({"/pageLogisticsCompany"})
    public QueryResults<LogisticsCompany> pageLogisticsCompany(String name,String code,String remark,
                                                               int pageNum, int pageSize) {
        return this.logisticsCompanyService.pageLogisticsCompany(name,code,remark,pageNum,pageSize);
    }

    @ApiOperation(httpMethod = "POST", value = "保存物流公司")
    @RequestMapping({"/saveLogisticsCompany"})
    public Result saveLogisticsCompany(Long id,String name,String code,String remark) {
        return this.logisticsCompanyService.saveModel(name, code, remark);
    }
    @ApiOperation(httpMethod = "GET", value = "删除物流公司")
    @ApiImplicitParam(name = "logisticsCompanyId", value = "标识", dataTypeClass = Long.class, required = true)
    @RequestMapping({"/deleteLogisticsCompany"})
    public Result deleteLogisticsCompany(Long logisticsCompanyId) {
        return this.logisticsCompanyService.delete(logisticsCompanyId);
    }
    @ApiOperation(httpMethod = "GET", value = "物流公司详情")
    @ApiImplicitParam(name = "logisticsCompanyId", value = "标识", dataTypeClass = Long.class, required = true)
    @RequestMapping({"/detailLogisticsCompany"})
    public Result detailLogisticsCompany(Long logisticsCompanyId) {
        return this.logisticsCompanyService.findById(logisticsCompanyId);
    }

}
